package output;

import ontology.Ontology;
import java.util.List;
import lupos.Pos;

/** 
 * This class implements the 'dependent' elements of harvested 
 * lexical entry files. These have the following format:
 * 
 *   dependent @syntacticRole @syntacticCategory (@pform1 @pform2) @start @end
 *     > semanticrole 
 *     > text #CDATA
 * 
 */

public class Dependent implements Comparable<Dependent> {

	public String syntacticRole;
	public String syntacticCategory;
	public SemanticRole semanticRole;
	public String start;
	public String end;
	public String text;

	public Dependent(String synr,String sync,String semr,String semtype,String strt,String nd,Ontology o,String txt,List<Pos> pos) {
		syntacticRole = synr;
		syntacticCategory = sync;
		semanticRole = new SemanticRole(semr,semtype,o);
		start = strt;
		end = nd;
		text = txt;
	}

	public String toXML() {
		String s = "        <dependent syntacticRole=\"";
		s = s + syntacticRole + "\" syntacticCategory=\"";
		s = s + syntacticCategory + "\" ";
		s = s + "start=\"" + start + "\" end=\"";		
		s = s + end + "\">\n";
		s = s + semanticRole.toXML(10);
		s = s + "          <text><![CDATA[" + text + "]]></text>\n";
		return s + "        </dependent>\n";
	}
	
	public int compareTo(Dependent d) {
		if (Integer.parseInt(this.start) < Integer.parseInt(d.start)) return -1;
		else return 1;
	}
	
}
